package tianrun.ziguan.api.calculate.config.service.influxdb.impl;


import tianrun.ziguan.api.calculate.config.service.influxdb.TableName;

import java.math.BigDecimal;

public class InsertValue implements TableName<InsertValue> {

    private String assetNum;
    private Long time;
    private Double value;
    private String label;

    public String getAssetNum() {
        return assetNum;
    }

    public InsertValue setAssetNum(String assetNum) {
        this.assetNum = assetNum;
        return this;
    }

    public Long getTime() {
        return time;
    }

    public InsertValue setTime(Long time) {
        this.time = time;
        return this;
    }

    public Double getValue() {
        return value;
    }

    public InsertValue setValue(Double value) {
        this.value = value;
        return this;
    }

    @Override
    public String getTableName() {
        return this.assetNum;
    }

    public String getLabel() {
        return label;
    }

    public InsertValue setLabel(String label) {
        this.label = label;
        return this;
    }

    @Override
    public TableName<InsertValue> setTableName(String tableName) {
        if (tableName.contains("_")) {
            tableName = tableName.substring(0, tableName.indexOf("_"));
        }
        this.assetNum = tableName;
        return this;
    }

    public InsertValue() {
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof InsertValue)) return false;

        InsertValue timeValue = (InsertValue) o;

        if (getAssetNum() != null ? !getAssetNum().equals(timeValue.getAssetNum()) : timeValue.getAssetNum() != null)
            return false;
        if (getTime() != null ? !getTime().equals(timeValue.getTime()) : timeValue.getTime() != null) return false;
        return getLabel() != null ? getLabel().equals(timeValue.getLabel()) : timeValue.getLabel() == null;
    }

    @Override
    public int hashCode() {
        int result = getAssetNum() != null ? getAssetNum().hashCode() : 0;
        result = 31 * result + (getTime() != null ? getTime().hashCode() : 0);
        result = 31 * result + (getLabel() != null ? getLabel().hashCode() : 0);
        return result;
    }
}
